Repository navigation
fix: Keep pagination iterators advancing past fully-filtered pages - #964
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #964 +/- ##
==========================================
- Coverage 94.64% 94.62% -0.02%
==========================================
Files 58 58
Lines 5263 5246 -17
==========================================
- Hits 4981 4964 -17
Misses 282 282
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
vdusek
marked this pull request as ready for review
July 21, 2026 08:07
Pijukatel
approved these changes
Jul 22, 2026
Pijukatel
left a comment
Contributor
There was a problem hiding this comment.
Can you please check the JS implementation as well
Contributor
Author
|
issue in JS repo apify/apify-client-js#979 |
This was referenced Sep 4, 2026
Merged
vdusek
added a commit
to apify/apify-client-js
that referenced
this pull request
Sep 11, 2026
…1044) ### TLDR - Mirrors apify/apify-client-python#964, which fixed the same bug in the Python client. - The API-side root cause is described in apify/apify-core#27324. - Closes: #979 ### Description The offset-based iterator stopped as soon as a page came back with no items, and advanced the offset by the number of items returned. Dataset filters (`clean`, `skipEmpty`, `skipHidden`) apply after `offset` and `limit`, so a page can scan up to `limit` rows while returning fewer, or none at all. `listItems()` used as an async iterable therefore ended early on a fully filtered page, and re-yielded rows an earlier page had already returned. The iterator now paginates by the scanned count the API reports in `x-apify-pagination-count`, and by that number alone. `items.length` cannot stand in for it in either direction: filters leave it below the rows scanned and `unwind` can leave it above, so mixing the two would skip rows. `PaginatedList.count` stays `items.length`, since it is public and intentionally set that way; the scanned number travels with the page as a non-enumerable symbol property outside the public shape. Collection endpoints send no such header and fall back to `items.length`, so nothing about them changes. The cursor iterators (`listKeys()`, `listRequests()`, `paginateRequests()`) are unchanged. The API never returns an empty page together with a cursor: the request queue listing hands out `nextCursor` only when it filled the whole page, and the key-value store listing derives `nextExclusiveStartKey` from the last key it returned. ### Test plan Regression tests for the fully filtered page, the duplicated offset, and `unwind` returning more items than rows scanned. ### Breaking change When `DatasetClient.listItems()` is consumed as an async iterable, `limit` caps the dataset rows the API scans, as it does on a single call, where v2 counted the items yielded. With `clean`, `skipEmpty` or `skipHidden` set, the loop can yield fewer than `limit` items, each of them once. v2 made up the difference with items it had already yielded, or stopped early on an empty page. With `unwind` the loop can yield more. The v3 upgrading guide covers it. *✍️ Drafted by Claude Code*
B4nan
pushed a commit
to apify/apify-client-js
that referenced
this pull request
Sep 30, 2026
…1044) ### TLDR - Mirrors apify/apify-client-python#964, which fixed the same bug in the Python client. - The API-side root cause is described in apify/apify-core#27324. - Closes: #979 ### Description The offset-based iterator stopped as soon as a page came back with no items, and advanced the offset by the number of items returned. Dataset filters (`clean`, `skipEmpty`, `skipHidden`) apply after `offset` and `limit`, so a page can scan up to `limit` rows while returning fewer, or none at all. `listItems()` used as an async iterable therefore ended early on a fully filtered page, and re-yielded rows an earlier page had already returned. The iterator now paginates by the scanned count the API reports in `x-apify-pagination-count`, and by that number alone. `items.length` cannot stand in for it in either direction: filters leave it below the rows scanned and `unwind` can leave it above, so mixing the two would skip rows. `PaginatedList.count` stays `items.length`, since it is public and intentionally set that way; the scanned number travels with the page as a non-enumerable symbol property outside the public shape. Collection endpoints send no such header and fall back to `items.length`, so nothing about them changes. The cursor iterators (`listKeys()`, `listRequests()`, `paginateRequests()`) are unchanged. The API never returns an empty page together with a cursor: the request queue listing hands out `nextCursor` only when it filled the whole page, and the key-value store listing derives `nextExclusiveStartKey` from the last key it returned. ### Test plan Regression tests for the fully filtered page, the duplicated offset, and `unwind` returning more items than rows scanned. ### Breaking change When `DatasetClient.listItems()` is consumed as an async iterable, `limit` caps the dataset rows the API scans, as it does on a single call, where v2 counted the items yielded. With `clean`, `skipEmpty` or `skipHidden` set, the loop can yield fewer than `limit` items, each of them once. v2 made up the difference with items it had already yielded, or stopped early on an empty page. With `unwind` the loop can yield more. The v3 upgrading guide covers it. *✍️ Drafted by Claude Code*
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The offset- and cursor-based pagination iterators stopped as soon as a page's
itemslist came back empty. But under dataset filters (clean,skip_empty,skip_hidden), the API can scan a full chunk (up to 1000 items) while returning none —items=[]withx-apify-pagination-count: 1000. The iterators broke on that page and silently never yielded any item behind it, even though the offset bookkeeping (max(count, len(items))) had already advanced past the scanned rows.Now all four iterators (offset + cursor, sync + async) terminate on the number of items scanned rather than returned: they keep advancing the offset/cursor across fully-filtered pages and stop only when a page scans nothing. The
limitandcursor is Nonechecks are unchanged. Behavior is identical for every response without a divergentcount(collection endpoints,ListOfRequests).Added a regression test for each of the four iterators.
Related to https://github.com/apify/apify-core/issues/27324.
✍️ Drafted by Claude Code